﻿@foreach (var item in Model) {
    <div class="item">
        <a href="@((item.activity_ex != null && item.activity_ex.is_sold_out == false 
                    && (item.activity_ex.begin_time <= DateTime.Now || (item.activity_ex.preheat_time != null && item.activity_ex.preheat_time <= DateTime.Now)) && item.activity_ex.end_time >= DateTime.Now)
                            ? "/DistributionMall/ProductDetail?productId=" + item.id :"javascript:void(0)")">
            <div class="itemBox relative">
                @if (item.activity_ex != null && item.activity_ex.begin_time <= DateTime.Now && item.activity_ex.end_time >= DateTime.Now) {
                    if (item.activity_ex.is_sold_out == true) {
                        <div class="out absolute"></div>
                    }
                }
                <div class="mao absolute"></div>
                <div class="img">
                    <img src="@item.main_image_url">
                </div>
                <div class="text">
                    <div class="tit fn-nowrap fn28 mb10">@item.name</div>
                    <div class="pri col-red mb10">
                        <em class="fn24">狂欢价</em><span class="mr10"><em class="fn48">@(item.price.ToString("f2"))</em></span>
                         <br />
                        <em class="col-gray5 through fn22">原价@((item.market_price > item.price ? item.market_price : item.price).ToString("f2"))</em>
                    </div>
                    <div>
                        @if (item.activity_ex != null && item.activity_ex.begin_time <= DateTime.Now && item.activity_ex.end_time >= DateTime.Now) {
                            if (item.activity_ex.is_sold_out == false) {
                                <span class="btn">立即购买</span>
                            } else {
                                <span class="btn cancel">已售罄</span>
                            }
                        } else if (item.activity_ex != null && item.activity_ex.end_time > DateTime.Now && item.activity_ex.begin_time > DateTime.Now) {
                            <span class="btn cancel">即将开始</span>

                        } else {
                            <span class="btn cancel">已结束</span>
                        }

                    </div>
                </div>
            </div>
        </a>
    </div>
}